/*
Copyright (c) 2012 by karmaleaving@qq.com. All rights RESERVED.
*/
#ifndef __STD_STACK_H_VERSION_KL__
#define __STD_STACK_H_VERSION_KL__

#include "memory.h"
#include "deque.h"

KL_BEGIN
// CLASS stack {
template<typename Type, typename Container = deque<Type>>
class stack
{
public:
	KL_TYPE_DEFINE(Type);
protected:
	Container _c;
public:
	stack()
	{
	}
	stack(stack const &o)
		: _c(o._c)
	{
	}
	bool empty()
	{
		return _c.empty();
	}
	void pop()
	{
		_c.pop_back();
	}
	void push(const_reference value)
	{
		_c.push_back(value);
	}
	size_type size()
	{
		return _c.size();
	}
	const_reference top() const
	{
		return _c.back();
	}
	reference top()
	{
		return _c.back();
	}
	void swap(stack &o)
	{
		_c.swap(o);
	}
#ifdef _USE_KL_EXTRA
	typedef Container container_type;
	container_type &get_container()
	{
		return _c;
	}
	container_type const &get_container() const
	{
		return _c;
	}
#endif // _USE_KL_EXTRA
};
// CLASS stack }
// FUNCTION swap (for stack) {
template<typename Type, typename Container>
inline void swap(stack<Type, Container> &left, stack<Type, Container> &right)
{
	left.swap(right);
}
// FUNCTION swap (for stack) }
KL_END

#endif // __STD_STACK_H_VERSION_KL__
